<template>
    <div style="padding:20px;">
        <el-table :data="records">
            <el-table-column prop="userNick" label="打赏人" width="150">
            </el-table-column>
            <el-table-column prop="giftName" label="礼物名称" width="150">
            </el-table-column>
            <el-table-column prop="amount" label="总数量" width="150">
            </el-table-column>
            <el-table-column prop="totalPrice" label="总金额" width="150">
            </el-table-column>
            <el-table-column prop="roomId" label="房间号" width="120">
            </el-table-column>
            <el-table-column prop="status" label="打赏状态" width="120">
                <template slot-scope="scope">
                            <el-tag
                            :type="scope.row.打赏状态 == 0 ? 'primary' : 'success'"
                            close-transition>{{scope.row.打赏状态 ? "未支付" : "已支付"}}</el-tag>
                </template>
            </el-table-column>
            <el-table-column prop="createTime" label="打赏时间" width="200">
            </el-table-column>
            <!-- <el-table-column label="操作">
                <template slot-scope="scope">
                    <el-button
                    size="mini"
                    type="danger"
                    @click="removeRecord(scope.$index, scope.row)">删除</el-button>
                </template>
            </el-table-column> -->
        </el-table>

    </div>
</template>

<script>
import { parseTime } from '../../utils';
export default {
    name: 'giftRecords',
    data() {
        return {
            records: [],
            pageInfo: {}
        };
    },
    methods: {
        queryAll(tag) {
            let params = {
                pageNum: 1,
                pageSize: 10
            };
            if (tag) {
                params.status = tag;
            }
            this.$ajax
                .get('/giftRecord/queryAll', {
                    params
                })
                .then(res => {
                    const { list, pageNum, pageSize, pages, total } = res.data;
                    this.records = list.map(item => {
                        item.createTime = parseTime(item.createTime);
                        item.totalPrice = item.totalPrice / 100 + '金币';
                        return item;
                    });
                    this.pageInfo = {
                        pageNum,
                        pageSize,
                        pages,
                        total
                    };
                });
        }
    },
    mounted() {
        this.queryAll();
    }
};
</script>

